<template>
	<view class="container">
		<view class="view_flex q_type block">
			<view class="title">反馈类型</view>
			<view class="q_input">
				<picker mode="selector" :range="vdata.qType" :value="vdata.qTypeIndex" @change="onChangeHandle">
					{{ vdata.qTypeIndex === null ? '内容问题/功能问题/操作问题/其他' : vdata.qType[vdata.qTypeIndex] }}
				</picker>
			</view>
		</view>
		
		<view class="block">
			<view class="view_flex q_desc">
				<view class="title">问题描述</view>
				<view class="q_input">
					<textarea placeholder="请填写问题描述" v-model="vdata.qDesc"></textarea>
				</view>
			</view>
			<view class="view_flex q_img">
				<view class="title">问题截屏/视频</view>
				<view class="q_input">
					
				</view>
			</view>
		</view>
		
		<button plain class="q_btn" @click="onSubmitHandle">提交</button>
		
		
		
	</view>
	
	<view class="canvas_container" :style="{ left: vdata.left + 'px' }">
		<canvas canvas-id="canvas"></canvas>
		<button>保存海报</button>
	</view>
</template>

<script setup>
	import { reactive } from 'vue'
	
	// 数据源
	const vdata = reactive({
		qType:["内容问题","功能问题","操作问题","其他"],	// 反馈类型
		qTypeIndex: null,	// 选择的问题类型
		
		qDesc: '',	// 问题描述
		
		left: 800
	})
	
	/**
	 * 问题类型选择
	 */
	const onChangeHandle = (e) => {
		
	}
	/**
	 * 提交
	 */
	const onSubmitHandle = () => {
		const ctx = uni.createCanvasContext('canvas')
		
		uni.downloadFile({
			url: 'https://img.shetu66.com/2022/08/cutCoverImg/1663066003507479.jpg',
			success({ tempFilePath }) {
				ctx.drawImage(tempFilePath,0, 0, 280, 450)
				ctx.setFontSize(20)
				
				const metrics = ctx.measureText('二维码位置')
				
				
				ctx.fillText('二维码位置', 230 - metrics.width, 400)
				
				ctx.draw()
				
				vdata.left = 0
			}
		})
	}
	
</script>

<style lang="less" scoped>
	.canvas_container{
		width: 100%;
		height: 100vh;
		background-color: rgba(0, 0, 0, 0.5);
		position: fixed;
		top: 0;
		left: 600px;
		z-index: 999;
		transition: all 0.5s;
		
		canvas{
			width: 280px;
			height: 450px;
			background-color: #f1f5f9;
			margin: 80px auto;
		}
	}
	
	
	// 公共
	.view_flex{
		display: flex;
		align-items: center;
		justify-content: space-between;
		flex-wrap: wrap;
	}
	.block{
		background-color: #fff;
		border-radius: 18rpx;
		padding: 24rpx;
		
		&:nth-child(2){
			margin-top: 24rpx;
		}
	}
	
	.container{
		width: 100%;
		min-height: 100vh;
		background-color: #f1f5f9;
		padding: 36rpx;
		box-sizing: border-box;
		
		.q_desc,.q_img{
			&>view{
				width: 100%;
				.q_input{
					width: 100%;
				}
			}
		}
		
		
	}
</style>